package file;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class Test8 {
    public static void main(String[] args) {
        //try with resources 把要释放的资源，放到try()然后就会自动调用到关闭 无论是否异常
        //要求try（）里面的对象能够实现Closeable接口
        try (InputStream inputStream = new FileInputStream("test/test.txt")) {
            int b;
            while (true) {
                b = inputStream.read();
                if (b == -1) {
                    break;
                }
                System.out.printf("%c", b);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
